package com.luguangtao.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.luguangtao.entity.Student;
import com.luguangtao.entity.StudentExample;
import com.luguangtao.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class StuController {

    @Autowired
    StudentMapper studentMapper;

    @RequestMapping("list1")
    public PageInfo<Student> lists(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "3")Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<Student> students = studentMapper.selectByExample(new StudentExample());
        PageInfo<Student> studentPageInfo = new PageInfo<>(students);
        return studentPageInfo;
    }
}
